package com.piece.module.generator.service;

import com.piece.core.jpa.repository.BaseService;
import com.piece.module.generator.model.TbSysValidate;
import com.piece.module.generator.repository.TbSysValidateRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class TbSysValidateService extends BaseService<TbSysValidate, String> {

    @Resource
    private TbSysValidateRepository tbSysValidateRepository;

    @PostConstruct
    public void initRepository() {
        setRepository(tbSysValidateRepository);
    }

    /**
     * 根据ColumnId查询
     */
    public List<TbSysValidate> findByColumnId(Long columnId) {
        HashMap<String, Object> condition = new HashMap<>();
        condition.put("columnId", columnId);
        return findByCondition(condition);
    }

    public int deleteByColumnId(Long columnId) {
        return tbSysValidateRepository.deleteByProperties("columnId", columnId);
    }
}
